package logica;

import java.io.Serializable;

import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import java.util.Calendar;
import java.util.List;


/**
 * 
 * The persistent class for the FACTURA database table.
 * 
 */
@Entity
@Table(name="FACTURA")
@NamedQuery(name="Factura.findAll", query="SELECT f FROM Factura f")
public class Factura implements Serializable {
	private static final long serialVersionUID = 1L;
	private int idFactura;
	private double importetotal;
	private Calendar fechaFacturacion;
	private String nombre;
	private String tipofactura;
	private List<Consumo> consumos;
	private Estadia estadia;
	private Notadecredito notadecredito;
	private Pago pago;
	private Paga paga;
	private boolean estadiaFacturada;

	public Factura() {
	}


	@Id
	@SequenceGenerator(name="FACTURA_IDFACTURA_GENERATOR", sequenceName="SECUENCIA")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="FACTURA_IDFACTURA_GENERATOR")
	@Column(name="ID_FACTURA", unique=true, nullable=false, precision=8)
	public int getIdFactura() {
		return this.idFactura;
	}

	public void setIdFactura(int idFactura) {
		this.idFactura = idFactura;
	}

	@Column(name="IMPORTETOTAL", nullable=false, precision=126)
	public double getImporteTotal() {
		return this.importetotal;
	}


	public void setImporteTotal(double total) {
		this.importetotal = total;
	}

	@Temporal(TemporalType.DATE)
	@Column(name="FECHA_FACTURACION", nullable=false)
	public Calendar getFechaFacturacion() {
		return this.fechaFacturacion;
	}

	public void setFechaFacturacion(Calendar fechaFacturacion) {
		this.fechaFacturacion = fechaFacturacion;
	}


	@Column(nullable=false, length=50)
	public String getNombre() {
		return this.nombre;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}


	@Column(nullable=false, length=5)
	public String getTipofactura() {
		return this.tipofactura;
	}

	public void setTipofactura(String tipofactura) {
		this.tipofactura = tipofactura;
	}


	//uni-directional many-to-many association to Consumo
	@ManyToMany
	@JoinTable(
		name="INCLUYE"
		, joinColumns={
			@JoinColumn(name="ID_FACTURA", nullable=false)
			}
		, inverseJoinColumns={
			@JoinColumn(name="ID_CONSUMO", nullable=false)
			}
		)
	
	public List<Consumo> getConsumos() {
		return this.consumos;
	}

	public void setConsumos(List<Consumo> consumos) {
		this.consumos = consumos;
	}


	//uni-directional one-to-one association to Estadia
	@ManyToOne
	@JoinColumn(name="ID_ESTADIA", nullable=false)
	public Estadia getEstadia() {
		return this.estadia;
	}

	public void setEstadia(Estadia estadia) {
		this.estadia = estadia;
	}


	//bi-directional many-to-one association to Notadecredito
	@ManyToOne
	@JoinColumn(name="ID_NOTA")
	public Notadecredito getNotadecredito() {
		return this.notadecredito;
	}

	public void setNotadecredito(Notadecredito notadecredito) {
		this.notadecredito = notadecredito;
	}


	//uni-directional one-to-one association to Pago
	//@OneToOne
	//@JoinColumn(name="ID_FACTURA", referencedColumnName="ID_FACTURA", nullable=false)
	@OneToOne(mappedBy="factura")
	public Pago getPago() {
		return this.pago;
	}

	public void setPago(Pago pago) {
		this.pago = pago;
	}


	//uni-directional one-to-one association to Paga
	//@OneToOne
	//@JoinColumn(name="ID_FACTURA", referencedColumnName="ID_FACTURA", nullable=false, insertable=false, updatable=false)
	@OneToOne(mappedBy="factura")
	public Paga getPaga() {
		return this.paga;
	}

	public void setPaga(Paga paga) {
		this.paga = paga;
	}

	@Column(name="BANDERA",  nullable=false, precision=1)
	public boolean isEstadiaFacturada() {
		return estadiaFacturada;
	}


	public void setEstadiaFacturada(boolean estadiaFacturada) {
		this.estadiaFacturada = estadiaFacturada;
	}


}